<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="custom-image" content="https://totemlife.cn/apps/public/trial-home-cover.jpg">
    <title>查看参试日志</title>
    <link href="/apps/css/bootstrap.min.css" rel="stylesheet">
    <link href="/apps/css/fontawesome-free-6.4.0-web/css/all.css" rel="stylesheet">
    <script src="/apps/js/baidu-tongji-mtx.js"></script>
</head>
<body>
    <div class="container py-4">
        <div class="row mb-4">
            <div class="col">
                <h2>
                    <a href="/apps/trial" class="text-decoration-none">临床研究支持</a>
                    <i class="fas fa-chevron-right mx-2"></i>
                    {{#if isAdmin}}
                    <a href="/apps/trial/admin/trials/{{trial.id}}/subjects" class="text-decoration-none">受试者管理</a>
                    <i class="fas fa-chevron-right mx-2"></i>
                    <a href="/apps/trial/diary/list/{{trial.id}}?subject_id={{diary.subject_id}}" class="text-decoration-none">参试日志</a>
                    {{else}}
                    <a href="/apps/trial/diary/list/{{trial.id}}" class="text-decoration-none">参试日志</a>
                    {{/if}}
                    <i class="fas fa-chevron-right mx-2"></i>
                    {{formatDate diary.diary_date "YYYY-MM-DD"}}
                </h2>
            </div>
            <div class="col-auto">
                {{#unless isAdmin}}
                {{#if (eq diary.user_id ../userId)}}
                <a href="/apps/trial/diary/{{diary.id}}/edit" class="btn btn-primary">
                    <i class="fas fa-edit me-1"></i>编辑
                </a>
                {{/if}}
                {{/unless}}
            </div>
        </div>

        <!-- 基础信息 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">基础信息</h5>
                <div class="row g-3">
                    <div class="col-md-12">
                        <strong>记录日期：</strong>{{formatDate diary.diary_date "YYYY-MM-DD"}}
                        <strong>早餐服用：</strong>{{diary.morning_dose}} {{diary.morning_missed_reason}} {{diary.morning_missed_other}}
                        <strong>晚餐服用：</strong>{{diary.evening_dose}} {{diary.morning_missed_reason}} {{diary.morning_missed_other}}
                        <strong>不良反应：</strong>{{diary.side_effects}} {{diary.side_effects_other}}
                        <strong>训练时长：</strong>{{diary.training_duration}}<br>
                        <strong>进展情况：</strong>{{diary.progress}}
                    </div>
                </div>
            </div>
        </div>

        <!-- 延展信息 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">排便情况</h5>
                <div class="row g-3">
                    <div class="col-md-3">
                        <p class="mb-1"><strong>次数：</strong>{{diary.stool_times}}</p>
                    </div>
                    <div class="col-md-3">
                        <p class="mb-1"><strong>形状：</strong>{{diary.stool_type}}</p>
                    </div>
                    <div class="col-md-3">
                        <p class="mb-1"><strong>颜色：</strong>{{diary.stool_color}}</p>
                    </div>
                    {{#if diary.stool_abnormal}}
                    <div class="col-12">
                        <p class="mb-1"><strong>异常状况：</strong></p>
                        <p class="text-muted mb-0">{{diary.stool_abnormal}}</p>
                    </div>
                    {{/if}}
                </div>
            </div>
        </div>

        <!-- 饮食记录 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">饮食记录</h5>
                <div class="row g-3">
                    <div class="col-md-6">
                        <p class="mb-1"><strong>早餐：</strong>{{diary.breakfast}}</p>
                        <p class="mb-1"><strong>午餐：</strong>{{diary.lunch}}</p>
                        <p class="mb-1"><strong>晚餐：</strong>{{diary.dinner}}</p>
                    </div>
                    <div class="col-md-6">
                        <p class="mb-1"><strong>营养补充：</strong>{{diary.supplements}}</p>
                        <p class="mb-1"><strong>食欲变化：</strong>{{diary.appetite}}</p>
                        <p class="mb-1"><strong>变化说明：</strong>{{diary.appetite_note}}</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 睡眠情况 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">睡眠情况</h5>
                <div class="row g-3">
                    <div class="col-md-4">
                        <p class="mb-1"><strong>睡眠时长：</strong>{{diary.sleep_duration}}</p>
                    </div>
                    <div class="col-md-4">
                        <p class="mb-1"><strong>睡眠质量：</strong>{{diary.sleep_quality}}</p>
                    </div>
                    <div class="col-md-4">
                        <p class="mb-1"><strong>备注：</strong>{{diary.sleep_note}}</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 环境变化 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">环境变化</h5>
                <p class="mb-1"><strong>变化：</strong>{{diary.environment_changes}}</p>
            </div>
        </div>

        <!-- 总结 -->
        <div class="card mb-4">
            <div class="card-body">
                <h5 class="card-title">总结</h5>
                <p class="mb-1"><strong>总结：</strong>{{diary.summary}}</p>
            </div>
        </div>

        <!-- 参考照片/视频 -->
        {{#if diary.content}}
            {{#with (parseJson diary.content)}}
                {{#if media_files}}
                    <div class="card mb-4">
                        <div class="card-body">
                            <h5 class="card-title">参考照片/视频</h5>
                            <div class="list-group">
                                {{#each (parseJson media_files)}}
                                    <a href="{{url}}" target="_blank" class="list-group-item list-group-item-action">
                                        <i class="fas fa-file me-2"></i>{{name}}
                                    </a>
                                {{/each}}
                            </div>
                        </div>
                    </div>
                {{/if}}
            {{/with}}
        {{/if}}

    </div>

    <!-- 将所有JS文件移到这里，并添加defer属性 -->
    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js" defer></script>
    <script src="/apps/js/bootstrap.bundle.min.js" defer></script>
    <script src="/apps/js/wx-client-dom.js" defer></script>

</body>
</html> 
